import request from '@/config/axios'

// 检验记录 VO
export interface InspectionRecordVO {
  id: number // 主键id
  serialNo: string // 序列号（物料编号）
  recordCode: string // 检验记录编号
  orderCode: string // 工单号
  materialsNum: string // 物料品号
  typeId: number // 检验类型id（字典维护）
  lineId: number // 产线id
  processId: number // 工序id
  status: number // 检测结果（1合格 2返工 3报废）（字典维护）
  remark: string // 备注
  creatorName: string // 检验人员姓名
  recordDetailList: Array<any> // 检测项目
}

// 检验记录 API
export const InspectionRecordApi = {

  // 查询预检信息
  getInspectionRecordQuery: async (params: any) => {
    return await request.get({ url: `/opticore/inspection-record/query`, params })
  },

  // 查询检验记录分页
  getInspectionRecordPage: async (params: any) => {
    return await request.get({ url: `/opticore/inspection-record/page`, params })
  },

  // 查询检验记录详情
  getInspectionRecord: async (id: number, param_type:any) => {
    return await request.get({ url: `/opticore/inspection-record/get?id=${id}&paramType=${param_type}`})
  },

  // 新增检验记录
  createInspectionRecord: async (data: InspectionRecordVO) => {
    return await request.post({ url: `/opticore/inspection-record/create`, data })
  },

  // 修改检验记录
  updateInspectionRecord: async (data: InspectionRecordVO) => {
    return await request.put({ url: `/opticore/inspection-record/update`, data })
  },

  // 删除检验记录
  deleteInspectionRecord: async (id: number) => {
    return await request.delete({ url: `/opticore/inspection-record/delete?id=` + id })
  },

  // 导出检验记录 Excel
  exportInspectionRecord: async (params) => {
    return await request.download({ url: `/opticore/inspection-record/export-excel`, params })
  }
}
